package com.example.shopping2.timmer

import android.os.Handler
import android.os.Message
import java.lang.ref.WeakReference

class TimmerHandler : Handler {
    private lateinit var weakReference: WeakReference<TimmerCallBack>

    constructor(timmerCallBack: TimmerCallBack) : super() {
        weakReference = WeakReference(timmerCallBack)
    }

    override fun handleMessage(msg: Message) {
        super.handleMessage(msg)
        var i = msg.obj as Int
        if (weakReference.get()!=null){
            weakReference.get()!!.callTimmer(i)
        }
    }


    interface TimmerCallBack {
        fun callTimmer(time:Int)
    }
}

